package p2;

import javafx.scene.transform.Scale;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2023-10-24
 * Time: 14:20
 */
public class exp2_1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int []arr = new int[n];
        for(int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr);
        int max = 0;//最大出现次数
        int count = 1;//当前数出现次数
        int maxNum = 0;//最大数字
        for(int i=1; i<n; i++){
            if(arr[i] == arr[i-1]){
                count++;
            } else {
                if( count>max){
                    max = count;
                    maxNum = arr[i-1];
                }
                count = 1;
            }

        }
        if(count > max){
            max = count;
            maxNum = arr[n-1];
        }
        System.out.println(maxNum + " " + max);
    }
}
